
define([
	'config/appregister',"business/special/service/http",'jquery'
],function(app,httpServices){
        app.directive('infoArea',function($state){
            return {
				scope:{
					dataList:'=data',
					infoIndex:'=index'
				},
				templateUrl:"app/business/special/template/infoArea.html",
                link:function(scope,element,attrs){
					scope.infoList=scope.dataList.fileList;
					var count=scope.dataList.fileCount;
					if(count<=10){
						scope.one=false;
						scope.two=false;
						scope.three=false;
					}else if(count>10&&count<=20){
						scope.one=true;
						scope.two=true;
						scope.three=false;
					}else if(count>20){
						scope.one=true;
						scope.two=true;
						scope.three=true;
					}

					scope.changePage=function(dir,index){
						if(dir=='pre'){
							scope.infoIndex-=1;
						}else if(dir=='next'){
							scope.infoIndex+=1;
						}else if(dir=='null'){
							if(scope.infoIndex==index){
								return;
							}
							scope.infoIndex=index;
						}
						if(scope.infoIndex<1){
							scope.infoIndex=1;
							return;
						}
						if(scope.infoIndex>3){
							scope.infoIndex=3;
							return;
						}
						$('.info-contaniner').css('opacity',0);
						$('.info-contaniner').stop().animate({'opacity':1},1000);
						getList();
					};

					scope.gotoList=function(){
						$state.go('material',{catalogId:scope.dataList.catalogId,type:1});
					};

					function getList(){
						var req = {
							type:"GET",
							uri:'getListByCatalogId',
							data:{
								type:1,
								catalogId:scope.dataList.catalogId,
								pageNo:scope.infoIndex,
								pageSize:10
							}
						};
						httpServices.specialHttpService(req).success(function(data){
							if(!data)return;
							scope.$apply(function(){
								if(data.code == 0) {
									scope.infoList=data.data.list
								}else {
									console.log(data.msg)
								}
							});
						}).error(function(){
							console.log("资料分页请求失败");
						});
					}
                }
            }
        })
      })


